#include <boost/asio.hpp> 
#include <boost/array.hpp> 
#include <iostream> 
#include <string> 

boost::asio::io_service service; 
boost::asio::ip::tcp::resolver resolver(service); 
boost::asio::ip::tcp::socket sock(service); 
boost::array<char, 4096> buffer; 

void read_handler(const boost::system::error_code &ec, std::size_t bytes_transferred) 
{ 
  if (!ec) 
  { 
    std::cout << std::string(buffer.data(), bytes_transferred) << std::endl; 
    sock.async_read_some(boost::asio::buffer(buffer), read_handler); 
  } 
} 

void connect_handler(const boost::system::error_code &ec) 
{ 
  if (!ec) 
  { 
    boost::asio::write(sock, boost::asio::buffer("GET / HTTP 1.1\r\nHost: highscore.de\r\n\r\n")); 
    sock.async_read_some(boost::asio::buffer(buffer), read_handler); 
  } 
} 

void resolve_handler(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator it) 
{ 
  if (!ec) 
  { 
    sock.async_connect(*it, connect_handler); 
  } 
} 
using namespace boost::asio;
int main() 
{ 
  //boost::asio::ip::tcp::resolver::query query("www.highscore.de", "80"); 
  //resolver.async_resolve(query, resolve_handler); 
  //io_service.run(); 

  ip::tcp::endpoint ep( ip::address::from_string("127.0.0.1"), 30051);
  ip::tcp::socket sock(service);
  sock.open(ip::tcp::v4()); 
  sock.connect(ep);
  //sock.write_some(buffer("GET /index.html\r\n"));
  char buff[1024] = {0}; 
  sock.read_some(boost::asio::buffer(buff,1024));
  
  std::cout<<"data received:"<<buff<<std::endl;

  sock.shutdown(ip::tcp::socket::shutdown_receive);
  sock.close();
} 
